#!/bin/sh
module="complete"
device="complete"
moduledir="/lib/modules/3.5.0-FriendlyARM-g042a5377-dirty"

if [ $1 == "r" ]; then
	echo remove $module
	modprobe -r $module
	exit
fi

cp /home/plg/$module.ko $moduledir
rm $moduledir/modules.dep.bb

rm -f /dev/${device}[0]

oldmodule=$(awk "\$2==\"$module\" {print \$2}" /proc/devices)
echo oldmoudle = $oldmodule

if [ $oldmodule == $module ]; then
    echo oldmoudle = $oldmodule
    modprobe -r $module
fi

echo modprobe $module
modprobe $module

major=$(awk "\$2==\"$module\" {print \$1}" /proc/devices)
echo major = $major
mknod /dev/${device}0 c $major 0 
ls -l /dev/$device*
